package com.morningstar.common.message;

import com.alibaba.fastjson2.JSON;
import com.morningstar.common.constants.QueueConstant;
import jakarta.annotation.Resource;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * 消息发送工具类
 *
 * @author morningstar
 * @since 2023/9/5
 */
@Component
public class MessageMqSender {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void send(BaseMessage abstractMessage) {
        rabbitTemplate.convertAndSend(QueueConstant.MESSAGE_QUEUE, JSON.toJSONString(abstractMessage));
    }
}
